On Ant
Readings *Ant Manual ** Path-like Structures ** Supported Conditions *External Tools and Tasks *Using Antlib props in Ant 1.8 *How can I do something like (double expanding the property)? * Ant: Using Saxon and XSLT 2.0 with Ant ** This works without nested element. * Using Saxon in Ant XSLT Task ** If you don't read this article, you would do really lots of trial and error to use Saxon XSLT processor with XSLT task of Ant. * Apache Ant/XQuery * java.io.IOException: CreateProcess: ... error=193 * executing javap from ant(Nov 8, 2001) * ant task to remove files from a jar (Mar 26 '10) * How to put a newline in ant property (Aug 18 '11) Pattern to Specify Files and Directories *Ant User Manual : Directory-based Tasks Ant Tasks * The Apache Ant Libraries Subproject * Antelope ** Tasks : http://antelope.tigris.org/nonav/docs/manual/bk03.html * Ant-Contrib Tasks ** Tasks : http://ant-contrib.sourceforge.net/tasks/tasks/ * Input task * AntForm/AntMenu ** AntForm provides an Ant task (see usage) for setting property values through a Swing-based form. * Antcount * WebLogic Server 9.0 Ant Tasks to configure and use a server domain * WebLogic Server 11.1 Ant Tasks to configure and use a server domain * WebLogic Server 11.1 Ant Tasks to deploy applications and modules : wldeploy * Tomcat Ant Tasks * Maven Ant Tasks * ant4eclipse ** provides a set of Ant tasks to make several configurations from the Eclipse IDE available in Ant buildscripts. * Ant-Eclipse ** a task for the Java build tool Ant generating Eclipse projects to be just imported and used easily. * SvnAnt ** an ant task that provides an interface to Subversion revision control system ** Setup : http://subclipse.tigris.org/svnant/introduction.html ** Tasks : http://subclipse.tigris.org/svnant/svntask.html ** Binaries : https://github.com/juhoffma/jboss-soe/tree/master/tools/svnant-1.3.1/lib * FindBugs Ant task * JXR Ant Task ** An Ant task for the JXR report. Based on the JXR Maven plugin ** License : the Apache License, Version 2.0 * JavaNCSS Ant Task ** Checks some basic code metrics and generates a report. ** Easily automate JSHint validation on your Javascript code base with Apache Ant. * Ant Task for Doxygen ** License : Apache License * JMeter Ant Task * Ant-Jshint * Ant tasks for markup conversion in Mylyn WikiText ** API for MarkupToHtmlTask class. ** API for MarkupToDocbookTask class. * xmltaks ** provides the facility for automatically editing XML files as part of an Ant build. * TestNG Ant Task * FMPP Ant task ** All FMPP settings Configuration Boilerplates Typical Configuration collaborating with Maven Title or descrption for this build file Defined properties : Classpath : ${project.classpath.list} Environment variable MAVEN_HOME should be specified properly. Typical Configuration collaborating with Maven, Jetty and Subversion Title or descrption for this build file Defined properties : Classpath : ${project.classpath.list} Parsed Version : major : ${ver.major} minor : ${ver.minor} incremental : ${ver.incremental} tail : ${ver.tail} Max revision under this project : ${revision.max} Environment variable MAVEN_HOME should be specified properly. Tips and Tricks Print classpath in Ant build file Sometimes, it can be convenient to print out classpath to console to confirm it is correctly setup in Ant build file. For this, you can use the expression ${toString:pathreference} like the following example ... ${toString:project.classpath} Listing members of fileset or path-like structure line by line For eye-checking or reporting purpose, sometimes it is necessary to list members of fileset each one in it's line. You can do this using pathconvert and echo tasks. The following is snippet used to list non-java files in source directories of Maven projects (which are multi-module form). ${nonjava.list} You can also list path-like structure line by line using task. ${classpath.main.list} Actually can also be applied to dirset, filelist, or propertyset as well. For details, refer http://ant.apache.org/manual/Tasks/pathconvert.html Including another path-like structure within a path-like structure If you want include a path-like structure to another, you can use like this. Note that you should not use . The value of path attribute in pathelement is expected to be string corresponding to path not id of path-like structure. The following would cause error. If you really want to use pathelement all the way, you can use toString function. The following would work. Note that ${java.class.path} which can be evaluated from default system properties of Java is just string corresponding to classpath and maven.plugin.classpath which is defined implicitly with maven-antrun-plugin is id of path-like structure. So, you should use them like the following. Printing environment variables To identify all the environment variables and their values defined within the process the current Ant build is running, you can use echo task with environment attribute. ... ... The above property task makes properties for all the environment variables in current process with the property names prefixed by 'env'. Applying pattern to Copy task As of Ant 1.7.1, copy task with only file attribute seems to ignore the glob or regexp mapper defined to the task. In this case you should use nested fileset element. The following task wouldn't work as is expected. But the following task would work. Concatenating values of multiple properties into a property Unlike what the name implies, pathconvert task can concatenate values of several properties into a property along with the nested propertyset task. pathconvert can work with nested resource collection. For more, refer http://ant.apache.org/manual/Tasks/pathconvert.html. The following sample create a phones property of which value is the concatenation of the values by phone.home, phone.mobile and phone.office and separated by comma. When names of properties to concatenate have a certain pattern like above, you can use prefix or regex instead of name with propertyref task. For more about propertyset, refer http://ant.apache.org/manual/Types/propertyset.html If you want concatenate only home and mobile phone numbers. Adding or removing files into/from a JAR file You can remove files from a archive file by repacking the archive file using zip or jar task. When repacking the archive, new files can be added also. The following sample removes log4j module and SLF4J/log4j binding module from the ActiveMQ Web Console artifact and adds logback modules using jar task. ... Copy a slightly modified(removed slf4j-log4j12-*.jar and log4j12-*.jar within) JAR file of ActiveMQ WebConsole and make necessary directories Querying properties in POM You can query the property values defined via Maven POM using Maven-Ant tasks. Defined properties : Maven properties java.version = ${project.pom.properties.java.version} spring.version = ${project.pom.properties.spring.version} mybatis.version = ${project.pom.properties.mybatis.version} akka.version = ${project.pom.properties.akka.version} camel.version = ${project.pom.properties.camel.version} activemq.version = ${project.pom.properties.activemq.version} jetty.version = ${project.pom.properties.jetty.version} Classpath : ${project.classpath.list} Where the pom.xml is ... UTF-8 UTF-8 false true false true true true 1.7 1.7.12 1.1.3 4.8.2 6.9.10 3.4 4.5.2 4.0.9.RELEASE 3.2.8 2.5.4 2.3.15 2.17.0 5.13.2 9.2.16.v20160414 false ... Querying revision number of subversion * SvnAnt introduction * SvnAnt tasks ** wcversion command * SVN Revision Numbers in Ant(04.01.07) Max revision under this project : ${revision.max} Generating HTML documentation for XML schema using xs3p Launch a executable via environment variable for the location To assure location transparency, it is preferred to define the base location for an application as an environment variable. In this case, to launch the application the existence of it can be verified using task beforehand.